package org.nowcoder.leetcode.BSearch;

import java.util.stream.IntStream;

public class LeetCode_34 {
    public int[] searchRange(int[] nums, int target) {
        //常规思路实现
        int[] result = IntStream.range(0, nums.length)
                .filter(k -> nums[k] == target)
                .toArray();
        if (result.length == 0) {
            return new int[]{-1, -1};
        }
        if (result.length == 1) {
            return new int[]{result[0], result[0]};
        }
        return new int[]{result[0], result[result.length - 1]};
    }
}
